package org.point.dao.impl;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import org.point.common.dao.impl.BaseDaoImpl;
import org.point.common.util.DoPage;
import org.point.dao.TransactionRecordDao;
import org.point.domain.TransactionRecord;
import org.point.domain.Users;
import org.springframework.stereotype.Repository;

/**
 * 
 * @ClassName: TransactionRecordDaoImpl
 * @Description: TODO(查询交易记录)
 * @author ljp
 * @date 2016年11月1日
 *
 */
@Repository("TransactionRecordDao")
public class TransactionRecordDaoImpl extends BaseDaoImpl<TransactionRecord, Serializable>
		implements TransactionRecordDao {

	private static final String SQLID_SEARCHTRANDRECORD = "search_trandrecord";

	private static final String SQLID_INSERTTRANDRECORD = "insert_trandrecord";

	private static final String SQLID_SEARCHCOUNT = "search_count_trandrecord";

	/**
	 * 利用反射，获取mapper.xml的namespace
	 * <p>
	 * Title:
	 * </p>
	 * <p>
	 * Description:
	 * </p>
	 */
	public TransactionRecordDaoImpl() {
		namespace = super.getNamespace();
	}

	public List<TransactionRecord> searchTrandRecord(DoPage<TransactionRecord> page) {
		// TODO 根据会员对象查询交易记录
		List<TransactionRecord> records = getSqlSession().selectList(namespace + SQLID_SEARCHTRANDRECORD, page);
		return records;
	}

	public Integer insertTrandRecord(TransactionRecord record) {
		// TODO 插入交易记录
		Integer result = getSqlSession().insert(namespace + SQLID_INSERTTRANDRECORD, record);
		return result;
	}

	public Integer countTrandForMem(DoPage<TransactionRecord> page) {
		// TODO Auto-generated method stub
		Integer result =0;
		try {
			result = getSqlSession().selectOne(namespace + SQLID_SEARCHCOUNT, page);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			throw new RuntimeException("统计交易记录数量出错"+e);
		}
		return result;
	}

}
